<template>
  <el-card shadow="never">
    <div class="btn-event">
      <el-input placeholder="请输入" style="width:340px;text-align: left;"></el-input>
      <el-button type="primary">搜索</el-button>
    </div>
    <el-table :data="tableData" style="width: 100%; margin-bottom: 20px" row-key="permissionId" border>
      <el-table-column prop="logId" label="日志id" sortable></el-table-column>
      <el-table-column prop="empId" label="用户id" sortable></el-table-column>
      <el-table-column prop="logTime" label="操作时间" sortable></el-table-column>
      <el-table-column prop="context" label="操作内容" sortable></el-table-column>
    </el-table>

    <el-dialog title="操作日志" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="日志编号" :label-width="formLabelWidth">
          <el-input v-model="form.logId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="用户编号" :label-width="formLabelWidth">
          <el-input v-model="form.userId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="日志时间" :label-width="formLabelWidth">
          <el-input v-model="form.logTime" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="日志内容" :label-width="formLabelWidth">
          <el-input v-model="form.context" autocomplete="off"></el-input>
        </el-form-item>


      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="saveOrUpdate()">确 定</el-button>
      </div>
    </el-dialog>

    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageInfo.page"
      :page-sizes="[5, 10, 15, 20]" :page-size="pageInfo.size" layout="total, sizes, prev, pager, next, jumper"
      :total="pageInfo.total">
    </el-pagination>
  </el-card>
</template>

<script>
import {
  selLog,
  doSaveOrUpdate
} from '@/api/log';
export default {
  mounted() {
    this.updateTable();
  },
  data() {
    return {
      tableData: [],
      dialogFormVisible: false,
      formLabelWidth: "180px",
      pageInfo: {
        total: 0,
        page: 1,
        size: 5,
      },
      form: {},
    };
  },
  methods: {

    updateTable() {
      selLog(this.pageInfo).then(r => {
        this.tableData = r.data.list;
        this.pageInfo.total = r.data.total;
      });
    },
    addUI() {
      (this.form = {}), (this.dialogFormVisible = true);
    },
    handleSizeChange(size) {
      this.pageInfo.size = size;
      this.updateTable();
    },
    handleCurrentChange(page) {
      this.pageInfo.page = page;
      this.updateTable();
    },
    handlePreview() { },
    handleRemove() { },

  }
};
</script>

<style lang="less" scoped>
.el-pagination {
  text-align: left;
  margin: 20px;
}

.btn-event {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 10px 0;

  .el-button {
    margin-left: 10px;
  }
}
</style>